"0","# What are the rownames showing?  "
"0","# Let's replace the sample ID in the fauna object (rownames) with the ages"
"0","# but only do this if the sample IDs match across objects"
"0","ages <- scpdAges$age"
"0","if (all(rownames(scpdFauna) == scpdAges$sample.id)){"
"0","  rownames(scpdFauna) <- ages"
"0","}"
"0","# set the names of the small mammal genera of interest"
"0","# note: this is a clunky workaround - ideally we'd be able to harmonize taxonomy using the database/API tools, but they aren't as good in Neotoma as in PBDB because of the way taxonomy is handled"
"0","sm_genus <- c(""Scapanus"", ""Microtus"", ""Neotoma"", ""Peromyscus"", ""Sorex"", ""Spermophilus"", ""Tamias"", ""Tamiasciurus"", ""Thomomys"", ""Arborimus"", ""Reithrodontomys"", ""Sciurus"", ""Glaucomys"", ""Myodes"", ""Aplodontia"")"
"0","# create a new dataframe with the merged data"
"0","scpdSM <- matrix(nrow=nrow(scpdFauna), ncol=length(sm_genus))"
"0","for (i in 1:length(sm_genus)){"
"0","  cols <- grep(sm_genus[i], colnames(scpdFauna))"
"0","  if (length(cols)==1){"
"0","    scpdSM[,i] <- scpdFauna[,cols]"
"0","  }"
"0","  if (length(cols) > 1){"
"0","    scpdSM[,i] <- rowSums(scpdFauna[,cols])"
"0","  }"
"0","  "
"0","}"
"0","# clean up dataframe"
"0","colnames(scpdSM) <- sm_genus"
"0","rownames(scpdSM) <- rownames(scpdFauna)"
